package com.yangfei.mystudy1020;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

import androidx.appcompat.app.AppCompatActivity;

import com.facebook.drawee.backends.pipeline.Fresco;
import com.kaolafm.kradio.k_launcher.activity.main.LauncherActivity;
import com.yangfei.mystudy1020.activity.AnimationActivity;
import com.yangfei.mystudy1020.activity.EventBusMainActivity;
import com.yangfei.mystudy1020.activity.FragManagementActivity;
import com.yangfei.mystudy1020.activity.GreenDaoTestActivity;
import com.yangfei.mystudy1020.activity.HandlerStudyAcitivity;
import com.yangfei.mystudy1020.activity.KRadioActivity;
import com.yangfei.mystudy1020.activity.KradioTestActivity;
import com.yangfei.mystudy1020.activity.LeakActivity;
import com.yangfei.mystudy1020.activity.MaskDrawActivity;
import com.yangfei.mystudy1020.activity.MinaClientActivity;
import com.yangfei.mystudy1020.activity.OGL20Activity;
import com.yangfei.mystudy1020.activity.RetrofitActivity;
import com.yangfei.mystudy1020.activity.RxjavaActivity;
import com.yangfei.mystudy1020.activity.SendIntentActivity;
import com.yangfei.mystudy1020.activity.SocketActivity;
import com.yangfei.mystudy1020.activity.SocketServerActivity;
import com.yangfei.mystudy1020.activity.TestFuncActivity;
import com.yangfei.mystudy1020.activity.TestGlideActivity;

public class MainActivity extends AppCompatActivity {

    Class[] mTestActivity={
            MaskDrawActivity.class,
            SocketActivity.class,
            SocketServerActivity.class,
            MinaClientActivity.class,
            EventBusMainActivity.class,
            GreenDaoTestActivity.class,
            TestGlideActivity.class,
            OGL20Activity.class,
            LeakActivity.class,
            TestFuncActivity.class,
            AnimationActivity.class,
            RxjavaActivity.class,
            SendIntentActivity.class,
            KRadioActivity.class,
            FragManagementActivity.class,
            HandlerStudyAcitivity.class,
            LauncherActivity.class,
            RetrofitActivity.class
    };

    Class mDefaultClass = null;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Fresco.initialize(this);
        setContentView(R.layout.activity_main);

        for(Class cls:mTestActivity){
            addNewTestActivity(cls, (ViewGroup) findViewById(R.id.ll_main));
        }

//        mDefaultClass = AnimationActivity.class;

        launchMainActivity();

    }

    private void launchMainActivity() {
        if(mDefaultClass!=null){
            Intent in = new Intent(MainActivity.this, mDefaultClass);
            MainActivity.this.startActivity(in);
        }
    }

    private void addNewTestActivity(final Class cls,ViewGroup root){
        Button btn = new Button(this);
        root.addView(btn);
        btn.setText(cls.getSimpleName());
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent in = new Intent(MainActivity.this, cls);
                MainActivity.this.startActivity(in);
            }
        });
    }

}
